package datasv.framework_datasv;

import data.datafactory.DatabaseOperator;
import resultmessage.FrameworkRM;

public class DeleteSubModel {
	public static void main(String[] args) {
		System.out.println(new DeleteSubModel().deleteSubModel("001", "00101", "001010301"));
	}
	public FrameworkRM deleteSubModel(String collegeID, String modelID, String SubModelID){
		return deleteInSql(collegeID, modelID, SubModelID);
	}
	private FrameworkRM deleteInSql(String collegeID, String modelID, String SubModelID){
		DatabaseOperator op=new DatabaseOperator("college"+collegeID);
		modelID=SubModelID.substring(0,7);
		if(!op.ifDatabaseExist()){
			return FrameworkRM.COLLEGEID_NOT_EXIST;
		}
		if(!op.ifIDExist("plan_model_list", modelID)){
			return FrameworkRM.MODELID_NOT_EXIST;
		}
		if(!op.ifIDExist("plan_submodel_list_"+modelID, SubModelID)){
			return FrameworkRM.SUBMODELID_NOT_EXIST;
		}
		if(op.deleteOneRow(SubModelID, "plan_submodel_list_"+modelID)){
			return FrameworkRM.SUCCESS;
		}
		return FrameworkRM.SUBMODELID_NOT_EXIST;
	}
}
